def sortFunc = {}

sortFunc = { data ->
	if (data.size() < 1) { return [] }
			def pivot = (data.size() / 2) as Integer
			def middle = data[pivot]

			def left = []
			def right = []

			for(i in 0..data.size() - 1) {
				if(i != pivot) {
					if(data[i] <= middle) {  // leftward, rightward spreading
						left += data[i]
					} else {
						right += data[i]
					}
				}
			}
			sortFunc(left) + middle + sortFunc(right)
}

def start = System.currentTimeMillis()

def list = []

def random = new Random()

(1..10000).each { list += random.nextInt(10000)}

def afterSortList = sortFunc(list)

def end = System.currentTimeMillis()
println end-start + "msec"



